PRG 1.0 TXT

/*
*/

//-----------------------------------------------------------------------------
// [CONFIG]

include "..\program_include.ocf"

object Program
{
	type		= e_program.DEPTH_AT;
	layer_bits	= e_render_layer_bits.SINGLE_SHADOWS;

	ubo_data	= array /*UBO*/ {
		{ "inShadow", e_program_data.SHADOW }
	}

	textures	= array /*ProgramTexture*/ {
		{ "unOpacityMap", e_texture.OPACITY }
	}
	
	uniforms	= array /*string*/ {
		"transform",		"unTransform."
		//"viewport_index",	"unLayer"
	}
}


//-----------------------------------------------------------------------------
// [VERTEX]

#version 330 core
#pragma optimize(on)

#define ATTR_POSITION	0
#define ATTR_TEXCOORD	2

layout(location = ATTR_POSITION) in vec3  inPosition;
layout(location = ATTR_TEXCOORD) in vec2  inTexcoord;

uniform struct TTransform {
	mat4	Shadow0;
} unTransform;

out	TVertexData {
	vec2	vTexcoord;
} Output;


void main()
{
	gl_Position 	 = unTransform.Shadow0 * vec4(inPosition, 1.0);
	Output.vTexcoord = inTexcoord;
}


//-----------------------------------------------------------------------------
// [GEOMETRY]

#version 330 core
#pragma optimize(on)

layout(triangles) in;
layout(triangle_strip, max_vertices = 3) out;

uniform int		unLayer;


in	TVertexData {
	vec2	vTexcoord;
} Input[];

out	TGeomData {
	vec2	vTexcoord;
} Output;


void main()
{
	gl_Layer = unLayer;

	gl_Position 	 = gl_in[0].gl_Position;
	Output.vTexcoord = Input[0].vTexcoord;
	EmitVertex();
	
	gl_Position 	 = gl_in[1].gl_Position;
	Output.vTexcoord = Input[1].vTexcoord;
	EmitVertex();
	
	gl_Position 	 = gl_in[2].gl_Position;
	Output.vTexcoord = Input[2].vTexcoord;
	EmitVertex();
	
	EndPrimitive();
}


//-----------------------------------------------------------------------------
// [FRAGMENT]

#version 330 core
#pragma optimize(on)

#define ALPHA_REF	0.1

uniform sampler2D	unOpacityMap;

in	TGeomData {
	vec2	vTexcoord;
} Input;


void main()
{
	float	alpha = texture( unOpacityMap, Input.vTexcoord ).a;
	
	if ( alpha < ALPHA_REF )
		discard;
}

// [END]
